<?php
session_start();
ini_set('max_execution_time', 60);
mysql_connect("127.0.0.1","root","");
mysql_select_db("test");
$time = time();
$id=$_SESSION['id'];
$_SESSION['id']=$id+1;
while((time() - $time) < 30) {
    $res=mysql_query("select * from msg where id=$id;");
	if(mysql_num_rows($res)==1)
	{
		$v=mysql_fetch_row($res);
		echo $v[1];
		break;
	}
	sleep(5);
}
?>